﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace Domain.Entity
{
    public partial class Game
    {
        public Game()
        {
            Id = 0;
            this.Reviews = new HashSet<Review>();
            this.Platforms = new List<Platform>();
            this.Reviews = new HashSet<Review>();
            this.Articles = new List<GameNewsArticle>();
            this.Pictures = new HashSet<Picture>();
            this.MetaScores = new List<MetaScore>();
        }

        [Key]
        [HiddenInput(DisplayValue = false)]
        public int Id { get; set; }

        [Required(ErrorMessage = "Please enter a Name")]
        public String Name { get; set; }

        [Required(ErrorMessage = "Please enter a Decription")]
        [DataType(DataType.MultilineText)]
        public String Description { get; set; }

        [HiddenInput(DisplayValue = false)]
        public Company Company{get; set;}

        [HiddenInput(DisplayValue = false)]
        [InverseProperty("Games")]
        public List<Platform> Platforms{get; set;}

        [Required(ErrorMessage = "Please enter a ContentRating")]
        public String ContentRating { get; set; }

        [Required(ErrorMessage = "Please enter a Relese Date")]
        [DataType(DataType.Date)]
        public DateTime ReleaseDate { get; set; }

        [Required(ErrorMessage = "Please enter a Genre")]
        public String Genre { get; set; }


        [HiddenInput(DisplayValue = false)]
        [InverseProperty("Game")]
        public virtual ICollection<Picture> Pictures { get; set; }
        
        [HiddenInput(DisplayValue = false)]
        public int NumRatings { get; set; }

        [HiddenInput(DisplayValue = false)]
        public int TotalRating { get; set; }

        [HiddenInput(DisplayValue = false)]
        public double AverageRating
        {
            get{ return (NumRatings == 0)? 0 : TotalRating / (double)NumRatings;}
        }

        [HiddenInput(DisplayValue = false)]
        public virtual ICollection<Review> Reviews { get; set; }

        public int PopularGameValue { get; set; }


        public String YoutubeLink { get; set; }
        public String FileName { get; set; }

        [InverseProperty("Game")]
        public ICollection<GameNewsArticle> Articles { get; set; }

        [InverseProperty("Game")]
        public virtual SystemRequirements SystemRequirements { get; set; }


        [HiddenInput(DisplayValue = false)]
        [InverseProperty("Game")]
        public ICollection<MetaScore> MetaScores { get; set; }

        [HiddenInput(DisplayValue = false)]
        public int NumberOfImages { get; set; }

        public DateTime? GameOftheWeekDate { get; set; }

    }
}